package com.example.mvplibrary.ui.activity;

import com.example.mvplibrary.model.BaseModel;
import com.example.mvplibrary.presenter.BasePresenter;
import com.example.mvplibrary.view.BaseView;

/**
 * 项目名：Shopping
 * 包名：  com.example.liangxq.ui.activity
 * 文件名：BaseMvpActivity
 * 创建者：liangxq
 * 创建时间：2021/3/16  11:22
 * 描述：TODO
 */
public abstract class BaseMvpActivity<V extends BaseView, M extends BaseModel, P extends BasePresenter<V, M>> extends BaseActivity {
    public P mPresenter;

    @Override
    protected void initData() {
        mPresenter = createPresenter();
        if (mPresenter != null) {
            mPresenter.bindView((V) this);
        }
        initEvent();
    }

    protected abstract void initEvent();

    protected abstract P createPresenter();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.destroyView();
            mPresenter = null;
        }
    }
}
